                   Messaging Gateway XML sample

The XML sample sets up two propagation jobs. One from an AQ queue to a
WebSphere MQ queue, and one from that same WebSphere MQ queue back to a
different AQ queue. The AQ queues accept payloads of type BOOK_ORDER_T.
This sample uses Oracle's XML facilities to transform messages from an 
ADT to an XML document and vice versa.

A sample transformation is provided and registered with Messaging Gateway
for transforming the payload to a string in the form of an XML document, 
then placing that string in the Messaging Gateway canonical type, 
SYS.MGW_BASIC_MSG_T, on an outbound propagation. A different sample 
transformation is provided for transforming a string in the form of an 
XML document pulled from a SYS.MGW_BASIC_MSG_T to a BOOK_ORDER_T payload 
on an inbound propagation.

Files 
----------
  create_users.sql
     Creates Oracle database users, MGWUSER, MGWAGENT, MGWADM needed for
     this sample

  create_queues.sql
     Creates AQ queues needed for this sample and the ADT BOOK_ORDER_T.

  trans_setup.sql
     Creates a package containing functions to be used as transformations 
     and registers transformations for 
     MGWUSER.BOOK_ORDER_T -> SYS.MGW_BASIC_MSG_T
     and SYS.MGW_BASIC_MSG_T -> MGWUSER.BOOK_ORDER_T.

  xml_adm_setup.sql
     Configures Messaging Gateway objects for propagating messages.
     This file must be altered by the user before it can be run.

  setup.sql
     Allows setup of this sample to be accomplished in one step. It calls
     create_users.sql, create_queues.sql, xml_adm_setup.sql

  xml_adm_cleanup.sql
     Removes the Messaging Gateway configuration for this sample.

  trans_drop.sql
     Unregisters the transformations registered by trans_setup.sql and
     drops the corresponding transformation function package. 

  drop_queues.sql
     Removes the AQ queues used for this sample.

  drop_users.sql
     Drops the Oracle database users used for this sample.

  cleanup.sql
     Calls trans_drop.sql and drop_queues.sql

  enq_xml.sql
     Enqueues a fixed message into the AQ queue used as the source for
     message propagation.

  deq_xml.sql
     Dequeues a message from the AQ queue used as the destination for
     message propagation. The message is discarded.


Configuring and running sample -- All files are SQL scripts
--------------------------------------------------------------
  1. Edit the script xml_adm_setup.sql (or a copy).
     There will be a block that looks as follows:
        --
        -- WARNING!!!! The values below must be set before this script is run.
        --
        begin
          :gv_database         := '';
          :gv_mq_queue_manager := '';
          :gv_mq_queue_name    := '';
          :gv_mq_channel       := '';
          :gv_mq_host          := '';
          :gv_mq_port          := '';
          :gv_mq_username      := '';
          :gv_mq_password      := '';
          :gv_mq_inbound_log_queue := '';
          :gv_mq_outbound_log_queue := '';
        end;

     Edit this block to include the appropriate values for these properties
     used for configuring a Messaging Gateway connection to WebSphere MQ.
     These values must refer to valid WebSphere MQ entities.

  2. As user, SYS as SYSDBA, run the script, setup.sql, to create the users
     MGWUSER, MGWAGENT, and MGWADM, create the AQ queues used by this sample,
     create the transformations, and configure Messaging Gateway objects 
     for propagating messages.

  3. As user, MGWADM (password MGWADM), start the Messaging Gateway agent

     e.g.  exec dbms_mgwadm.startup;

     Check the MGW_GATEWAY view and the log file (in ${ORACLE_HOME}/mgw/log) 
     to determine the status of the Messaging Gateway agent.

     e.g.  select agent_name, agent_status from MGW_GATEWAY;

  4. As user MGWUSER (password MGWUSER), enqueue a (fixed) message to the
     propagation source queue by running the script, enq_xml.sql.

  5. As user MGWADM, check that the message has been propagated.

     e.g.  select job_name, propagated_msgs, failures from MGW_JOBS;

     This will show the number of messages that have been propagated for
     each propagation job since the Messaging Gateway agent was started.

  6. Dequeue the message from the AQ queue by running the script deq_xml.sql.
     The script will return an error if no message is present. If a message
     is present it will be discarded.

Cleaning up the sample:
--------------------------------------------------------------
  1. As user MGWADM, before shutting down the Messaging Gateway agent, run
     the script, xml_adm_cleanup.sql, to clean up the MGW configuration.

  2. As user MGWADM, shut down the Messaging Gateway agent.

     e.g. exec dbms_mgwadm.shutdown

  3. When the Messaging Gateway agent is shut down, if desired, run the 
     script, cleanup.sql, to remove all transformations, packages, and 
     AQ queues used for this sample.

  4. Connect as SYS as SYSDBA and run drop_users.sql to remove Oracle 
     schemas created for this sample.
